package com.briup.sxau.conf;

import com.briup.sxau.web.Interceptor.SxauInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 自定义web配置类  实现接口WebMvcConfigurer
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    SxauInterceptor sxauInterceptor;

    //    方法是为项目添加拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //将指定拦截器注册到项目
//        registry.addInterceptor(new SxauInterceptor());

        registry.addInterceptor(sxauInterceptor)
//                直接放行的一些url  这些url请求的时候 是不会进到拦截器的
        .excludePathPatterns("/doc.html","/swagger-ui.html","/webjars/**","/v2/**","favicon.ico","/swagger-resources/**","/user/login");
    }
    //        javaConfig的方式将自定义拦截器对象交给SpringIOC容器
//    @Bean
//    private SxauInterceptor createInterceptor(){
//       return new  SxauInterceptor();
//    }

}
